#pragma once

#include <rapidxml/rapidxml.hpp>
#include <wx/wx.h>
#include <vector>
#include <Box2D/Box2D.h>
#include <resource_cache/resource_cache.hpp>
#include "animation.hpp"

struct kine_point
{
	kine_point() : time(0), angle(0) { point.x = 0; point.y = 0; }
	b2Vec2  point;
	float    time;
	float	 angle;
};

enum enum_shape_types
{
	shape_circle = 0,
	shape_polygon,
};
struct shape
{
	shape() : shape_type(0), is_sensor(false), current_polygon(-1), density(0), friction(0), restitution(0), circle_radius(0) { circle_offset.x=0; circle_offset.y=0; }
	int		 shape_type;

	std::string on_collide_message;
	bool     is_sensor;

	float	 density;
	float	 friction;
	float	 restitution;

	b2Vec2  circle_offset;
	float	 circle_radius;

	std::vector<b2Vec2> polygon_points;

	int current_polygon;
};


enum enum_body_types
{
	body_static = 0,
	body_kinematic,
	body_dynamic,
};
struct body
{
	body() : body_type(body_dynamic), angle(0), current_kinematic(-1), current_shape(-1), dampening(0), angular_dampening(0), fixed_angle(false) { name = "New Body"; position.x=0; position.y=0; }
	std::string name;
	std::vector<shape> shapes;
	int		 body_type;

	animation	animation_sprite;
	std::string	animation_file;
	void set_animation( std::string anim_file );

	float	 angle;	// all
	b2Vec2   position; // dynamic, static

	float	 dampening; // dynamic
	float	 angular_dampening; // dynamic
	bool	 fixed_angle; // dynamic

	std::vector<kine_point> kinematic_points; // kinematic

	int current_kinematic;
	int current_shape;
};


class slide
{
public:
	std::string	name;
	b2Vec2		gravity;
	sf::Sprite	background;
	std::string	background_file;
	std::vector<body> bodys;

	int current_body;

	bool set_background( std::string & file );

	slide(void) : current_body(-1) { name = "New Slide"; gravity.x=0; gravity.y=-9.8f; }
	~slide(void) {}
};
